use libc::c_void;
use zluaw::{State, RawStateWrapper, lua_c_functions};

lua_c_functions! {
    fn print_rs_string(lua: RawStateWrapper) -> i32 {
        let s: &mut String = lua.to_userdata(1);
        //let a: &mut i32 = lua.to_userdata(-2);
        println!("Rs String: {s}");
        0
    }

    fn print_rs_int(lua: RawStateWrapper) -> i32  {
        let s: &mut i32 = lua.to_userdata(1);
        println!("Rs Integer: {s}");
        0
    }

    fn hello(lua: RawStateWrapper) -> i32 {
        let c: &mut i32 = lua.to_userdata(1);
        let v = lua.to_integer(2);
        *c = v as i32;
        0
    }
}

fn main() {
    let lua = State::new();
    lua.open_libs();
    lua.do_string("function hello(x) print(x) end; hello(1)");
    
}